﻿<Application 
    x:Class="SandwichFlow.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mim="clr-namespace:MetroInMotionUtils"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:conv="clr-namespace:SandwichFlow.Converter"
    xmlns:behaviour="clr-namespace:WP7Contrib.View.Controls.Behaviors;assembly=WP7Contrib.View.Controls">

    <!--Application Resources-->
    <Application.Resources>
        <conv:SandwichCountConverter x:Key="SandwichCountConverter"/>

        <Style x:Key="mainFrameStyle"
        TargetType="phone:PhoneApplicationFrame">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="phone:PhoneApplicationFrame">
                        <Grid Background="White">
                            <!-- background image -->
                            <Image Source="Images/background.jpg"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"/>
                            <Border x:Name="ClientArea"
                      BorderBrush="{TemplateBinding BorderBrush}"
                      BorderThickness="{TemplateBinding BorderThickness}"
                      Background="{TemplateBinding Background}"
                      HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                      VerticalAlignment="{TemplateBinding VerticalAlignment}">
                                <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
                                  Content="{TemplateBinding Content}"
                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                  Margin="{TemplateBinding Padding}"
                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate  x:Key="KeywordTemplate">
            <StackPanel Orientation="Vertical"
                  Margin="0,5,0,5">
                <i:Interaction.Behaviors>
                    <behaviour:TiltBehaviour/>
                </i:Interaction.Behaviors>
                <TextBlock Text="{Binding Name}"
                           x:Name="Title"
                           FontSize="{StaticResource PhoneFontSizeLarge}"
                           behaviour:PivotSlideBehaviour.AnimationLevel="1"/>
                <TextBlock Text="{Binding Sandwiches.Count, Converter={StaticResource SandwichCountConverter}}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="#888"
                            behaviour:PivotSlideBehaviour.AnimationLevel="2"/>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="SandwichTemplate">
            <StackPanel Orientation="Vertical"
                  Margin="0,5,0,5">
                <i:Interaction.Behaviors>
                    <behaviour:TiltBehaviour/>
                </i:Interaction.Behaviors>
                <TextBlock  Text="{Binding Title}"
                            behaviour:PivotSlideBehaviour.AnimationLevel="1"
                            x:Name="Title"
                            Foreground="Black"
                            FontSize="{StaticResource PhoneFontSizeLarge}"/>
                <TextBlock Text="{Binding KeywordSummary}"
                            behaviour:PivotSlideBehaviour.AnimationLevel="2"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="#888"/>
            </StackPanel>
        </DataTemplate>
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService 
            Launching="Application_Launching" Closing="Application_Closing" 
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>